<template>
	<view class="service">
		<view class="service-card">
			<uni-card :is-shadow="false" :border="false" :margin="'20rpx'" :spacing="'40rpx 0'" :padding="0" >
				<view class="card-img">
					<image class="img" :src="data.wxImg" mode=""></image>
				</view>
				<view class="card-text">
					<view>
						<text class="text">微信号：</text><text class="text">{{data.wechat || ''}}</text>
					</view>
					<button class="but" plain @click="copy">复制</button>
				</view>
				<view class="card-text">
					<view >
						<text class="text">联系方式：</text><text class="text">{{data.tel || ''}}</text>
					</view>
					<!-- <button class="but" plain type="default" open-type="contact" @contact="getInfo">联系客服</button> -->
					<button class="but" plain @click="openTel"><image class="but-img" :src="imgUrl" mode="aspectFit"></image>拨号</button>
				</view>
			</uni-card>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgUrl:`${getApp().globalData.imgScr}jd/bohao.png`,
				data:{ // 客服相关信息
					tel:'', // 客服电话
					wechat:'', // 客服微信号
					wxImg:'', // 客服微信二维码
				}, 
			};
		},
		onLoad(option) {
			let _this = this
			this.$http.get('/index/Communal/config_data',{config_id:5}).
			then(function (res) {
				//这里只会在接口是成功状态返回
				_this.data.wxImg = res.customer_service_exqrcode.value[0]
				_this.data.wechat = res.customer_service_wechat.value
				_this.data.tel = res.customer_service_phone.value
				console.log('过滤的数据1',_this.data)
			}).catch(function (e) {
				//这里只会在接口是失败状态返回，不需要去处理错误提示
				uni.showToast({
					title: e.errMsg,
					icon:"none"
				})
			});
		},
		methods:{
			copy: function() {
				let _this = this
				uni.setClipboardData({
				    data: _this.data.wechat,
				    success: function () {
				        console.log('success');
				    }
				});
			},
			openTel: function() {
				let _this = this
				uni.makePhoneCall({
				    phoneNumber: _this.data.tel //仅为示例
				});
			}
		}
	}
</script>

<style lang="scss">
.service {
	height: 100vh;
	.service-card {
		flex: 1;
		overflow: auto;
		margin-bottom: 20rpx;
		.uni-card {
			border-radius: 20rpx;
			.uni-card__content {
				display: flex;
				flex-direction: column;
				align-items: center;
			}
		}
		.card-img {
			width: 368rpx;
			height: 368rpx;
			margin-bottom: 80rpx;
			.img {
				width: 100%;
				height: 100%;
			}
		}
		.card-text {
			display: flex;
			justify-content: space-between;
			align-items: center;
			width: 560rpx;
			height: 94rpx;
			border-radius: 20rpx;
			background-color: #F5F7FD;
			margin-bottom: 40rpx;
			padding: 0 40rpx;
			.text {
				font-size: 28rpx;
				color: #000000;
			}
			.but {
				background: linear-gradient(-90deg, #8dc9f1, #d8eefc);
				width: 170rpx;
				border-radius: 30rpx;
				line-height: 60rpx;
				font-size: 28rpx;
				font-weight: 500;
				color: #FFFFFF;
				border: 0;
				margin: 0;
				.but-img {
					width: 24rpx;
					height: 24rpx;
					margin-right: 10rpx;
				}
			}
		}
	}
}
</style>
